<?php


namespace App\Common;

/**
 * 常量定义类
 *
 * @package App\Common
 */
class Constant
{
    /*--------------------------单据审核状态--------------------------*/
    // 待审核
    const BIZ_STATE_WAIT_AUDIT = 'WAIT_AUDIT';
    // 审核通过
    const BIZ_STATE_APPROVED = 'APPROVED';
    // 审核拒绝
    const BIZ_STATE_REFUSED = 'REFUSED';

    /*--------------------------登录验证--------------------------*/
    // 登录方式 验证码登录
    const LOGIN_WAY_VCODE = 'VCODE';
    // 登录方式 密码登录
    const LOGIN_WAY_PWD = 'PWD';
    // 支持的登录场景
    const LOGIN_WAY_LIST = [
        self::LOGIN_WAY_VCODE,
        self::LOGIN_WAY_PWD
    ];
    // 获取验证码场景 注册
    const SMS_SCENE_REGISTER = 'register';
    // 获取验证码场景 登录
    const SMS_SCENE_LOGIN = 'login';
    // 支持的获取验证码场景
    const SMS_SCENE_LIST = [
        self::SMS_SCENE_LOGIN,
        self::SMS_SCENE_REGISTER
    ];
    // 图形验证码 -缓存前缀
    const CAPTCHA_PREFIX = 'hiyee-captcha-';
    const CAPTCHA_TTL = 5 * 60;

    /*--------------------------JWT配置--------------------------*/
    // Token 类型
    const JWT_TYPE_CUSTOMER = 'customer';
    const JWT_TYPE_ADMIN = 'admin';
    // Token 有效期4小时（秒）
    const JWT_TTL = 60 * 60 * 4;
    const JWT_PREFIX_CUSTOMER = 'customer_token_';

    /*--------------------------系统Kv配置--------------------------*/
    const KV_KEY_BASE_URL = 'site.base_url';
    const KV_KEY_USE_PWD = 'user.default.pwd';

    /*--------------------------系统分组类型--------------------------*/
    const GROUP_TYPE_USER = 'USER';
    const GROUP_TYPE_GOODS = 'GOODS';

    /*--------------------------文件类型--------------------------*/
    const FILE_URL_MEDIA = '/storage/';
    const FILE_UPLOAD_TYPE_IMG = 'image';
    const FILE_UPLOAD_TYPE_VIDEO = 'video';
    const FILE_UPLOAD_TYPE_AUDIO = 'audio';
    const FILE_UPLOAD_TYPE_ALLOWED = [
        self::FILE_UPLOAD_TYPE_IMG => 'required|image|max:10240',
        self::FILE_UPLOAD_TYPE_VIDEO => 'required|mimetypes:video/avi,video/mpeg,video/quicktime|max:50000',
        self::FILE_UPLOAD_TYPE_AUDIO => 'required|max:1024'
    ];
    const FILE_UPLOAD_STORAGE_DIR = [
        self::FILE_UPLOAD_TYPE_IMG => 'images',
        self::FILE_UPLOAD_TYPE_VIDEO => 'video',
        self::FILE_UPLOAD_TYPE_AUDIO => 'audio'
    ];

    /*--------------------------订单来源--------------------------*/
    const ORDER_FROM_H5 = 'H5';
    const ORDER_FROM_PC = 'PC';
    const ORDER_FROM_MAP = [
        self::ORDER_FROM_H5 => 'H5端',
        self::ORDER_FROM_PC => 'PC端',
    ];

    /*--------------------------订单状态--------------------------*/
    const ORDER_STATUS_CREATED = 'ORDER_CREATED';
    const ORDER_STATUS_CANCEL = 'ORDER_CANCEL';
    const ORDER_STATUS_WAIT_PAY = 'WAIT_PAY';
    const ORDER_STATUS_PAYED = 'ORDER_PAYED';
    const ORDER_STATUS_WAIT_DELIVERY = 'WAIT_DELIVERY';
    const ORDER_STATUS_DELIVERY_PART = 'DELIVERY_PART';
    const ORDER_STATUS_DELIVERY_ALL = 'DELIVERY_ALL';
    const ORDER_STATUS_RECEIVED = 'ORDER_RECEIVED';
    const ORDER_STATUS_FINISHED = 'ORDER_FINISHED';
    const ORDER_STATUS_DELETED = 'ORDER_DELETED';
    // 订单状态集合
    const ORDER_STATUS_MAP = [
        self::ORDER_STATUS_CREATED => '已下单',
        self::ORDER_STATUS_WAIT_PAY => '待支付',
        self::ORDER_STATUS_PAYED => '已付款',
        self::ORDER_STATUS_WAIT_DELIVERY => '待发货',
        self::ORDER_STATUS_DELIVERY_PART => '部分发货',
        self::ORDER_STATUS_DELIVERY_ALL => '全部发货',
        self::ORDER_STATUS_RECEIVED => '已收货',
        self::ORDER_STATUS_FINISHED => '已完成',
        self::ORDER_STATUS_CANCEL => '已取消',
        self::ORDER_STATUS_DELETED => '已删除'
    ];
    // 订单状态机集合
    const ORDER_STATUS_FLOW_MAP = [
        self::ORDER_STATUS_CANCEL => '已取消',
        self::ORDER_STATUS_CREATED => '待支付',
        self::ORDER_STATUS_PAYED => '待发货',
        self::ORDER_STATUS_DELIVERY_ALL => '待收货',
        self::ORDER_STATUS_FINISHED => '已完成'
    ];
    // 订单操作 - 可取消
    const ORDER_STATUS_CAN_CANCEL = [
        self::ORDER_STATUS_CREATED
    ];
    // 订单操作 - 可发货
    const ORDER_STATUS_CAN_DELIVERY = [
        self::ORDER_STATUS_PAYED
    ];
    // 订单操作 - 可收货
    const ORDER_STATUS_CAN_RECEIPT = [
        self::ORDER_STATUS_DELIVERY_PART,
        self::ORDER_STATUS_DELIVERY_ALL
    ];
    // 购买方式 - 购物车
    const ORDER_BUY_MODE_CART = 'cart';
    // 购买方式 - 立即购买
    const ORDER_BUY_MODE_FAST_BUY = 'fast-buy';
    // 购买方式 - 列表
    const ORDER_BUY_MODE_MAP = [
        self::ORDER_BUY_MODE_CART => '购物车',
        self::ORDER_BUY_MODE_FAST_BUY => '立即购买'
    ];

    /*--------------------------支付相关--------------------------*/
    // 订单支付状态 - 待支付
    const PAY_STATUS_WAIT_PAY = 'WAIT_PAY';
    // 订单支付状态 - 待支付
    const PAY_STATUS_PAYED = 'PAYED';
    // 支付状态集合
    const PAY_STATUS_MAP = [
      self::PAY_STATUS_WAIT_PAY => '待支付',
      self::PAY_STATUS_PAYED => '已支付'
    ];
    // 余额支付
    const PAY_METHOD_BALANCE = 'balance';
    // 支付方式集合
    const PAY_METHOD_MAP= [
        self::PAY_METHOD_BALANCE => '余额支付'
    ];

    /*--------------------------商品相关--------------------------*/
    // 商品单规格类型
    const GOODS_TYPE_SIMPLE = 'simple';
    // 商品多规格类型
    const GOODS_TYPE_MULTIPLE = 'multiple';
    // 商品类型集合
    const GOODS_TYPE_MAP = [
        self::GOODS_TYPE_SIMPLE => '单规格',
        self::GOODS_TYPE_MULTIPLE => '多规格'
    ];

    // 商品下架状态
    const GOODS_STATUS_DOWN = 0;
    // 商品上架状态
    const GOODS_STATUS_UP = 1;
    // 商品上下架状态集合
    const GOODS_STATUS_MAP = [
        self::GOODS_STATUS_DOWN => '下架',
        self::GOODS_STATUS_UP => '下架'
    ];

    // 商品发布平台PC
    const GOODS_PLATFORM_PC = 'PC';
    // 商品发布平台APP
    const GOODS_PLATFORM_APP = 'APP';
    // 商品发布平台H5
    const GOODS_PLATFORM_H5 = 'H5';
    // 商品发布平台MP
    const GOODS_PLATFORM_MP = 'MP';
    // 商品发布平台微信
    const GOODS_PLATFORM_WX = 'WX';
    // 商品发布平台列表
    const GOODS_PLATFORM_LIST = [
        self::GOODS_PLATFORM_PC,
        self::GOODS_PLATFORM_APP,
        self::GOODS_PLATFORM_MP,
        self::GOODS_PLATFORM_WX
    ];
    // 商品发布平台集合
    const GOODS_PLATFORM_MAP = [
        self::GOODS_PLATFORM_PC => 'PC端',
        self::GOODS_PLATFORM_APP => 'APP端',
        self::GOODS_PLATFORM_H5 => 'WAP端',
        self::GOODS_PLATFORM_MP => '小程序端',
        self::GOODS_PLATFORM_WX => '微信端'
    ];

    // 商品是/否标识
    const GOODS_FLAT_0 = 0;
    const GOODS_FLAT_1 = 1;
    const GOODS_FLAT_MAP = [
        self::GOODS_FLAT_0 => '否',
        self::GOODS_FLAT_1 => '是'
    ];

    /*--------------------------物流相关--------------------------*/
    // 配送方式 - 物流
    const DELIVERY_TYPE_EXPRESS = 'EXPRESS';
    // 配送方式 - 自提
    const DELIVERY_TYPE_ZITI = 'ZITI';
    // 配送方式列表
    const DELIVERY_TYPE_LIST = [
        self::DELIVERY_TYPE_EXPRESS => '物流配送',
        self::DELIVERY_TYPE_ZITI => '上门自提'
    ];

    /*--------------------------营销相关--------------------------*/
    // 优惠券发放对象类型 - 指定客户
    const COUPON_ASSIGN_TYPE_CUSTOMER = 'CUSTOMER';
    // 优惠券发放对象类型 - 客户群组
    const COUPON_ASSIGN_TYPE_GROUP = 'GROUP';
    // 优惠券发放对象类型列表
    const COUPON_ASSIGN_TYPE_MAP = [
        self::COUPON_ASSIGN_TYPE_CUSTOMER => '指定客户',
        self::COUPON_ASSIGN_TYPE_GROUP => '指定群组'
    ];

    /*--------------------------售后相关--------------------------*/
    // 售后申请单状态 - 待审核
    const AFTERSALES_APPLY_STATE_WAIT_AUDIT = 'WAIT_AUDIT';
    // 售后申请单状态 - 审核通过
    const AFTERSALES_APPLY_STATE_APPROVED = 'APPROVED';
    // 售后申请单状态 - 审核拒绝
    const AFTERSALES_APPLY_STATE_REFUSED = 'REFUSED';
    // 售后申请单状态 - 列表
    const AFTERSALES_APPLY_STATE_MAP = [
        self::AFTERSALES_APPLY_STATE_WAIT_AUDIT => '待审核',
        self::AFTERSALES_APPLY_STATE_APPROVED => '审核通过',
        self::AFTERSALES_APPLY_STATE_REFUSED => '审核拒绝'
    ];
    // 售后申请单类型 - 退货退款
    const AFTERSALES_APPLY_TYPE_RETURN = 'RETURN';
    // 售后申请单类型 - 换货
    const AFTERSALES_APPLY_TYPE_EXCHANGE = 'EXCHANGE';
}
